<div class="addtype_tab">
	<div class="bd" id="addClass">
		<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'memSub-form',
			'enableAjaxValidation'=>false,
		)); ?>
			<div class="add_type"><?php echo CHtml::link(Yii::t('cmp','Create Account').'<b class="mem_bgx left"></b><b class="mem_bgx right"></b>','#',array('onclick'=>'addAccount()','class'=>'mem_bgx link_btn click mr10 f_l'))?></div><br>
			<div class="type_list">
				<ul class="main_class">
				<?php foreach($section as $key=>$val){ ?>
					<li class="main_type">
						<div class="item">
							<ul class="c_f type">
								<li class="a"><span class="mem_ico ico_fold"></span>
									<?php echo CHtml::textField('setaction['.$key.']',$val,array('class'=>"t_ipt",'maxlength'=>'20'))?>
								</li> 
								<li class="b">
									<?php echo CHtml::link(Yii::t('glo','Delete'),array('DeleteAccount','id'=>$key),array('class'=>'c_06c'))?>
								</li>
							</ul>
						</div>
						<?php $memsub=Adminer::model()->findAllByAttributes(array('zpc_id'=>$key)) ?>
						<?php if(!empty($memsub)){?>
						<ul class="sub_class">
							<?php foreach($memsub as $val2){?>
							<li class="item">
								<ul class="c_f type">
									<li class="a"><span class="mem_ico ico_class"></span>
										<?php echo CHtml::textField('staff['.$val2->zda_id.']',$val2->zda_name,array('class'=>"t_ipt",'maxlength'=>'20'))?>
									</li>
									<li class="b">
										<?php //echo CHtml::link(Yii::t('cmp','Permission Setting'),'#',array('class'=>'c_06c'))?>
										<?php echo CHtml::link(Yii::t('glo','Update'),array('updateStaff','id'=>$val2->zda_id),array('class'=>'c_06c'))?>
										<?php echo CHtml::link(Yii::t('glo','Delete'),array('deleteStaff','id'=>$val2->zda_id),array('class'=>'c_06c'))?>
									</li>
								</ul>
							</li>
							<?php } ?>
						</ul>
						<?php }?>
					</li>
				<?php } ?>
				</ul>
			</div>
			<div class="add_type">
				<?php echo CHtml::link(Yii::t('cmp','Create Account').'<b class="mem_bgx left"></b><b class="mem_bgx right"></b>','#',array('onclick'=>'addAccount()','class'=>'mem_bgx link_btn click mr10 f_l'))?>
				<?php echo CHtml::submitButton(Yii::t('cmp','Save'),array('class'=>'mem_btn mem_btn13'))?>
			</div>
		<?php $this->endWidget(); ?>
	</div>
</div>	

<script type="text/javascript">
function addAccount(){
	art.dialog({
	    title: '新建部门',
	    content: '部门名称:<input type="text" id="newtitle" name="name"/>',
	    height: '100px',
	    width: '300px',
	    okValue: '保存',
	    cancelValue: '取消',
	    cancel: function () {},
	    ok:function () {
			var a = $('#newtitle').val();
			if(a.length<1){
				alert('部门名称不能为空！');
				return false;
			}
			window.location.href = "<?php echo $this->pre_module_url?>/memSub/account/title/"+a;
		}
	});
}

$('.mem_ico').bind('click',function(){
	//$(this).parent().parent().parent().next('ul').toggle();
	$(this).parent().parent().parent().parent().toggleClass('open');
});

//权限列表弹框
function setRole(){
	art.dialog({
	    title: '角色授权：<?php echo CHtml::checkBoxList('rule','',CmpCat::model()->getCmpRole(),array('separator'=>'\t'))?>',
	    content: '<?php echo  CHtml::endForm(); ?>
		    	<?php echo CHtml::label("角色权限：","task",array("class"=>"tit")); 
		    	  	$tasks = MemGroup::model()->getCmpTask();
		    		foreach($tasks as $key=>$val){
		    			echo "<li class=\"item\"><label>".$val."</label><ul class=\"sub_list ml10\">";
		    			echo CHtml::checkBoxList("privilege[$key][]",'',MemGroup::model()->getTaskAction($key),array("checkAll"=>"all","template"=>"<li class=\"f_l\">{input}{label}&nbsp;&nbsp;</li>","separator"=>""))."<br>";
		    			echo "</ul></li>";
		    		}
		    	?>',
	    height: '100px',
	    width: '500px',
	    okValue: '保存',
	    cancelValue: '取消',
	    cancel: function () {},
	    ok:function () {
			var a = $('#newtitle').val();
			window.location.href = "<?php echo $this->pre_module_url?>/memSub/account/title/"+a;
		}
	});
}
</script>